home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7148 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: nntp.teleport.com!usenet
  2. From: GHouck <hksys@teleport.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Arrow keys in DOS
  5. Date: 22 Feb 1996 01:06:02 GMT
  6. Organization: systems hk
  7. Message-ID: <4ggfhq$qnh@maureen.teleport.com>
  8. References: <312A7CDB.7010@wolfenet.com>
  9. NNTP-Posting-Host: ip-pdx12-38.teleport.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
  14.  
  15. Michael Gooding <mgooding@wolfenet.com> wrote:
  16. >How would one go about trapping and interpreting arrow keys in a DOS 
  17. >program written in BC++ 4.5
  18.  
  19. Michael,
  20.  
  21. I use this little program any time I want to determine a key's
  22. value.  It dumps the multi-byte values for the arrow-keys as
  23. well:  It is DOS and Borland-specific.
  24.  
  25. Yours, Geoff Houck
  26. /* ----------------------------------------------------
  27. key.c -- display key values (until ESC is hit)
  28. ---------------------------------------------------- */
  29. int  main ( void )
  30. {
  31.   int    chr = 0;
  32.   int    last = 0;
  33.  
  34.   while( chr != 27 ) {   /* loop until an ESC */
  35.     if( kbhit() ) {      /* key pressed?      */
  36.       chr = getch();     /* get the key       */
  37.       if( last == 0 )    /* multi-scan code ? */
  38.         printf( "  <%c> %3u.d %2X.x %03o.o",chr,chr,chr,chr );
  39.       else
  40.         printf( "\n<%c> %3u.d %2X.x %03o.o",chr,chr,chr,chr );
  41.       last = chr;
  42.     }
  43.   }
  44. }
  45.  
  46.  
  47.